<?php
/**
 * Plugin Name: NX Custom Sort Plugin
 * Description: A plugin to create custom sorted lists for posts/products with drag-and-drop and visit tracking.
 * Version: 1.0.0
 * Author: Your Name
 * License: GPL-2.0+
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

define('NX_CUSTOM_SORT_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('NX_CUSTOM_SORT_PLUGIN_URL', plugin_dir_url(__FILE__));

// Include necessary files
require_once NX_CUSTOM_SORT_PLUGIN_DIR . 'includes/class-nx-custom-sort-db.php';
require_once NX_CUSTOM_SORT_PLUGIN_DIR . 'includes/class-nx-custom-sort-admin.php';
require_once NX_CUSTOM_SORT_PLUGIN_DIR . 'includes/class-nx-custom-sort-frontend.php';
require_once NX_CUSTOM_SORT_PLUGIN_DIR . 'includes/class-nx-custom-sort-ajax.php';

class NX_Custom_Sort_Plugin {
    public function __construct() {
        // Initialize database
        register_activation_hook(__FILE__, [$this, 'activate']);
        // Initialize classes
        add_action('plugins_loaded', [$this, 'init']);
    }

    public function activate() {
        NX_Custom_Sort_DB::create_tables();
    }

    public function init() {
        new NX_Custom_Sort_Admin();
        new NX_Custom_Sort_Frontend();
        new NX_Custom_Sort_Ajax();
    }
}

new NX_Custom_Sort_Plugin();

?>
